<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        姓名： {{fullName}}
        <button @click="changeName">修改计算属性</button>
    </div>
    <script src="js/vue.global.js"></script>
    <script>
        const CounterApp = {
            data() {
                return {
                    firstName: '陈',
                    lastName: '恒'
                }
            },
            methods: {
                changeName() {
                    this.fullName = "张 三"
                }
            },
            computed: {
                fullName: {
                    get() {
                        return this.firstName + this.lastName
                    },
                    set(newValue) {
                        var names = newValue.split(' ')
                        this.firstName = names[0]
                        this.lastName = names[1]
                    }
                }
            }
        }
        Vue.createApp(CounterApp).mount('#app')
    </script>

</body>

</html>